package com.jingdianjichi.swagger.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.Contact;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("ape-frame")
                        .description("示例项目接口文档")
                        .version("1.0")
                        .contact(new Contact()
                                .name("jingdianjichi")
                                .url("http://gitdizhi")
                                .email("yh@qq.com")));
    }
    @Bean
    public GroupedOpenApi userApi() {
        return GroupedOpenApi.builder()
                .group("user")  // 分组名称
                .packagesToScan("com.jingdianjichi.user.controller") // 扫描的包路径
                .build();
    }

    /**
     * 订单模块API分组
     */
    @Bean
    public GroupedOpenApi orderApi() {
        return GroupedOpenApi.builder()
                .group("order")
                .packagesToScan("com.jingdianjichi.order.controller")
                .build();
    }

    /**
     * 默认分组（包含所有接口）
     */
    @Bean
    public GroupedOpenApi defaultApi() {
        return GroupedOpenApi.builder()
                .group("default")
                .packagesToScan("com.jingdianjichi")
                .build();
    }
}
